package uk.ac.cam.echo.app;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AchievementArrayAdapter extends ArrayAdapter<Achievement>
{

	public AchievementArrayAdapter(Context context, int resource, int textViewResourceId, Achievement[] objects)
	{
		super(context, resource, textViewResourceId, objects);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		TextView headerTv = new TextView(super.getContext());
		headerTv.setTextSize(30);
		headerTv.setText(getItem(position).name);
		headerTv.setTextColor(Color.BLACK);

		TextView descrTv = new TextView(super.getContext());
		descrTv.setTextSize(20);
		descrTv.setText(getItem(position).description);
		descrTv.setTextColor(Color.WHITE);

		LinearLayout firstLevel = new LinearLayout(super.getContext());
		firstLevel.setOrientation(LinearLayout.VERTICAL);
		firstLevel.addView(headerTv);
		firstLevel.addView(descrTv);

		CheckBox indicator = new CheckBox(super.getContext());
		indicator.setClickable(false);
		indicator.setChecked(getItem(position).achieved);
		indicator.setHeight(75);
		indicator.setWidth(75);
		indicator.setGravity(Gravity.RIGHT);

		LinearLayout secondLevel = new LinearLayout(super.getContext());
		secondLevel.addView(indicator);
		secondLevel.addView(firstLevel);
		secondLevel.setPadding(10, 10, 10, 10);
		// ViewGroup.LayoutParams params = new
		// android.widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
		// ViewGroup.LayoutParams.MATCH_PARENT);
		// secondLevel.setLayoutParams(params);

		return secondLevel;
	}
}